package com.company.project.service.impl;

import com.company.project.dao.ThesisGuideMapper;
import com.company.project.model.ThesisGuide;
import com.company.project.service.ThesisGuideService;
import com.company.project.core.AbstractService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;


/**
 * Created by CodeGenerator on 2018/10/09.
 */
@Service
@Transactional
public class ThesisGuideServiceImpl extends AbstractService<ThesisGuide> implements ThesisGuideService {
    @Resource
    private ThesisGuideMapper thesisGuideMapper;

    @Override
    public List<Map<String,Object>> selectThesisGuide() {
        return thesisGuideMapper.selectThesisGuide();
    }

    @Override
    public Boolean updateTG(ThesisGuide thesisGuide) {
        List<Map<String, Object>> maps = thesisGuideMapper.selectThesisGuide();
        if(maps.size()>0){
            Boolean aBoolean = thesisGuideMapper.updateTG(thesisGuide);
            return aBoolean;
        }else {
            int insert = thesisGuideMapper.insertTG(thesisGuide);
            if (insert>0){
                return true;
            }else {
                return false;
            }
        }
    }

    @Override
    public int insertTG(ThesisGuide thesisGuide) {
        return thesisGuideMapper.insertTG(thesisGuide);
    }

}
